package cn.edu.scau.cmi.wangzm.composite.safe;

import java.util.Iterator;
import java.util.Set;

public class SafeOutput {
	public void Output(SafeComposite trunk) {
  	  Set<SafeComponent> trunkChildren = trunk.getChildren();
		Iterator<SafeComponent> trunkChildrenIterator = trunkChildren.iterator();
		System.out.println(trunk.getName());
		while(trunkChildrenIterator.hasNext()) {
			SafeComposite text=new SafeComposite();
			text=(SafeComposite)trunkChildrenIterator.next();
			System.out.println("    "+text.getName());
			if(text.getChildren()!=null) {
				Set<SafeComponent> BranchChildren = text.getChildren();
				Iterator<SafeComponent> BranchChildrenIterator = BranchChildren.iterator();
				while(BranchChildrenIterator.hasNext()) {
					System.out.println("      "+((SafeLeaf)BranchChildrenIterator.next()).getName());
				}
			}
			}
    }
}
